#include"Reactor.hpp"
#include"Connection.hpp"
#include"Listener.hpp"
#include<string>
#include"Prase.hpp"
#include<memory>
#include"NetCalor.hpp"
void UseageOfReactor(char* ch[])
{
    std::cout << "Useage: " << ch[0] << " _port" << std::endl;
}




int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        UseageOfReactor(argv);
        exit(1);
    }
    std::unique_ptr<Calor> _cal = std::make_unique<Calor>();
    std::unique_ptr<PraseMessage> _prase = std::make_unique<PraseMessage>([&_cal](Demd _dema)->Result{
        return _cal->calor(_dema);
    });

    

    std::shared_ptr<Connection> _listener = std::make_shared<Listener>(std::stoi(argv[1]),[&_prase](std::string& buffer)
    ->std::string{
        return _prase->Prase(buffer);
    });
    std::unique_ptr<Reactor> _R = std::make_unique<Reactor>();


    _R->AddConnection(_listener);
    _R->Dispatcher();




    return 0;
}



